﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;
using vite_entity.Entities;

namespace vite_entity.EntityTypeConfig
{
    public class SysUser_TypeConfig : IEntityTypeConfiguration<SysUser>
    {
        public void Configure(EntityTypeBuilder<SysUser> entity)
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity
                .ToTable("sys_user", tb => tb.HasComment("用户信息表"))
                .UseCollation("utf8mb4_general_ci");

            entity.HasIndex(e => e.Username, "login_name").IsUnique();

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Avatar)
                .HasMaxLength(255)
                .HasDefaultValueSql("''")
                .HasComment("用户头像")
                .HasColumnName("avatar");
            entity.Property(e => e.CreateBy)
                .HasComment("创建人ID")
                .HasColumnName("create_by");
            entity.Property(e => e.CreateTime)
                .HasComment("创建时间")
                .HasColumnType("datetime")
                .HasColumnName("create_time");
            entity.Property(e => e.DeptId)
                .HasComment("部门ID")
                .HasColumnName("dept_id");
            entity.Property(e => e.Email)
                .HasMaxLength(128)
                .HasComment("用户邮箱")
                .HasColumnName("email");
            entity.Property(e => e.Gender)
                .HasDefaultValueSql("'1'")
                .HasComment("性别((1-男 2-女 0-保密)")
                .HasColumnName("gender");
            entity.Property(e => e.IsDeleted)
                .HasDefaultValueSql("'0'")
                .HasComment("逻辑删除标识(0-未删除 1-已删除)")
                .HasColumnName("is_deleted");
            entity.Property(e => e.Mobile)
                .HasMaxLength(20)
                .HasComment("联系方式")
                .HasColumnName("mobile");
            entity.Property(e => e.Nickname)
                .HasMaxLength(64)
                .HasComment("昵称")
                .HasColumnName("nickname");
            entity.Property(e => e.Password)
                .HasMaxLength(100)
                .HasComment("密码")
                .HasColumnName("password");
            entity.Property(e => e.Status)
                .HasDefaultValueSql("'1'")
                .HasComment("状态((1-正常 0-禁用)")
                .HasColumnName("status");
            entity.Property(e => e.UpdateBy)
                .HasComment("修改人ID")
                .HasColumnName("update_by");
            entity.Property(e => e.UpdateTime)
                .HasComment("更新时间")
                .HasColumnType("datetime")
                .HasColumnName("update_time");
            entity.Property(e => e.Username)
                .HasMaxLength(64)
                .HasComment("用户名")
                .HasColumnName("username");
        }
    }
}
